import {ref} from "vue";
import {UseWebsocket} from "@/utils/useWebsocket";
import {socketUrl} from "@/settings/designSetting";

const ws = ref<UseWebsocket | null>(null)

if (ws.value === null) {
    ws.value = new UseWebsocket(socketUrl)
    ws.value.connectionSocket()
}


const useWsSend = (id: string) => {
    if (ws.value !== null) {
        ws.value.send({componentId: id, type: 0})
    }
}

export {ws, useWsSend}
